package reader.components;

import java.util.Map;

import reader.xml.XMLContext;
import reader.xml.XMLHelper;

import components.AbstractComponent;
import components.Panel;

public class PanelRW extends AbstractComponentRW {

    private static final String LAYOUT = "layout";

    public PanelRW(Map<String, AbstractComponent> opened) {
        super(opened);
    }

    @Override
    public void read(AbstractComponent component, XMLContext context) {
        Panel panel = (Panel) component;
        super.read(component, context);
        panel.setLayout(XMLHelper.readStringProperty(context, LAYOUT));
    }

    @Override
    public void write(AbstractComponent component, XMLContext context) {
        Panel panel = (Panel) component;
        XMLHelper.writeProperty(context, LAYOUT, panel.getLayout());
        super.write(component, context);
    }

}
